Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Error de suscripción de GraphQL no controlado [Error: no se puede desestructurar la propiedad 'datos' de 'indefinido' porque no está definido].

Intento usar subscribeToMore para mi consulta de graphql en react-native, pero tengo el siguiente problema:

 ERROR: Unhandled GraphQL subscription error [Error: Cannot destructure property 'data' of 'undefined' as it is undefined.]

Mi suscripción parece

 // MESSAGE_SUBSCRIPTION import { gql } from '@apollo/client' export const TOPIC_MESSAGE_SUBSCRIPTION = gql` subscription MessageSubscription($data: SubscriptionInput!) { messageSubscription(data: $data) { _id text } } `

mi componente

 ... subscribeToMore({ document: MESSAGE_SUBSCRIPTION, variables: { data: { _id: params._id, }, }, updateQuery: (prev, { subscriptionData }) => { if (!subscriptionData.data) return prev console.log(prev, subscriptionData) return prev }, }) ...

Cuando pruebo el subscriton en mi patio de recreo todo funciona bien.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La configuración de mi apolloClient faltaba la conexión websocket.

También necesito agregar la autorización como parámetro, para obtenerla como contexto

 const wsLink = new WebSocketLink({ uri: Platform.select({ ios: 'ws://localhost:4000/', android: 'ws://10.0.2.2:4000/', }), options: { reconnect: true, connectionParams: async () => { const result = await getToken() return { authorization: result ? `Bearer ${result.password}` : '', } }, }, }) .... export const client = new ApolloClient({ link: split( ({ query }) => { const definition = getMainDefinition(query) return ( definition.kind === 'OperationDefinition' && definition.operation === 'subscription' ) }, authLink.concat(wsLink as any), authLink.concat(httpLink as any) ), cache: new InMemoryCache(), })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!